package com.huarui.saleOrder.dao.impl;

import java.util.List;
import java.util.Map;

import org.ewaf.framework.dao.impl.BaseDaoImpl;

import com.huarui.saleOrder.dao.ISaleOrderDao;

public class SaleOrderDaoImpl extends BaseDaoImpl implements ISaleOrderDao{

	@Override
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> querySaleOrdersListByComplex(
			Map<String, Object> paramsMap) {
		return (List<Map<String, Object>>) this.getSqlMapClientTemplate().queryForList(super.namespace + ".getSaleOrderInfoByComplex", paramsMap);
	}

	@Override
	public Integer querySaleOrdersListCountByComplex(Map<String, Object> paramsMap) {
		return (Integer) this.getSqlMapClientTemplate().queryForObject(super.namespace + ".getSaleOrderCountByComplex", paramsMap);
	}
	
	@Override
	public boolean takeOverPurchaseOrder(Map<String, Object> paramsMap) {
		return 1 == this.getSqlMapClientTemplate().update(super.namespace + ".takeOverPurchase", paramsMap);
	}
	
	@Override
	@SuppressWarnings("unchecked")
	public Map<String, Object> loadSaleOrderById(Map<String, Object> paramsMap) {
		return (Map<String, Object>) this.getSqlMapClientTemplate().queryForObject(super.namespace + ".getSaleOrderById", paramsMap);
	}

	@Override
	public boolean updateSaleOrderCurrentor(Map<String, Object> paramsMap) {
		return 1 == this.getSqlMapClientTemplate().update(super.namespace + ".updateSaleOrderCurrentor", paramsMap);
	}

	@Override
	public boolean turnBackPurchaseOrder(Map<String, Object> paramsMap) {
		return 1 == this.getSqlMapClientTemplate().update(super.namespace + ".turnBackPurchaseOrder", paramsMap);
	}
	
	@Override
	public boolean deleteById(Object id) {
		return 1 == this.getSqlMapClientTemplate().update(super.namespace + ".deleteById", id);
	}

	@Override
	public boolean updateSaleOrderStatus(Map<String, Object> map) {
		return getSqlMapClientTemplate().update(namespace+".updateSaleOrderStatus", map) == 1;
		
		
	}

	@Override
	public boolean clearSaleOrderCurrentorById(Integer id) {		
		return getSqlMapClientTemplate().update(namespace+".clearSaleOrderCurrentorById",id) == 1;
	}

	@SuppressWarnings("unchecked")
	@Override
	public Map getSaleOrderForMapById(Integer orderId) {
		return (Map) getSqlMapClientTemplate().queryForObject(namespace + ".getSaleOrderForMapById", orderId);
	}

}
